const path = require('path')

const resolve = dir => {
    return path.join(__dirname, dir)
}

// function addStyleResource(rule) {
//     rule.use('style-resource')
//         .loader('style-resources-loader')
//         .options({
//             patterns: [path.resolve(__dirname, './src/assets/css/imports.scss')]
//         });
// }

module.exports = {
    lintOnSave: false,
    productionSourceMap: false,
    devServer: {
        open: true,
        port: 8001,
        overlay: {
            errors: true,
            warnings: true
        }
    },
    configureWebpack: {
        externals: {
            "echarts": "echarts"
        },
    },
    chainWebpack: config => {
        config.resolve.alias
            .set('@', resolve('src')) // key,value自行定义，比如.set('@@', resolve('src/components'))
            .set('_c', resolve('src/components'))
            .set('_m', resolve('src/components/modules'))
            .set('_p', resolve('src/components/pages'))

        config
            .plugin('html')
            .tap(args => {
                args[0].title = '你的标题'
                return args
            })


        // const types = ["vue-modules", "vue", "normal-modules", "normal"];
        // types.forEach((type) =>
        //     addStyleResource(config.module.rule("scss").oneOf(type))
        // );

    }
}